package com.world;
/**
 * ChunkQube represents state and properties of chuk's cube. Data stored in {@link long} field, each property
 * in one byte. One high byte is reserved.
 * @author CrashTUA
 *
 */
public class ChunkQube {
	private long qubeData;

	/**
	 * Create ChunkQube from already formed data.
	 * 
	 * @param qubeData
	 */
	public ChunkQube(long qubeData) {
		this.qubeData = qubeData;
	}

	/**
	 * Create ChunkQube with specified data.
	 * 
	 * @param filled
	 *            1 if filled, otherwise 0
	 * @param rightTexture
	 *            right texture id
	 * @param leftTexture
	 *            left texture id
	 * @param frontTexture
	 *            front texture id
	 * @param backTexture
	 *            back texture id
	 * @param topTexture
	 *            top texture id
	 * @param bottomTexture
	 *            bottom texture id
	 */
	public ChunkQube(byte filled, byte rightTexture, byte leftTexture,
			byte frontTexture, byte backTexture, byte topTexture,
			byte bottomTexture) {
		qubeData = (long) filled << (8 * 6);
		qubeData += (long) bottomTexture << (8 * 5);
		qubeData += (long) topTexture << (8 * 4);
		qubeData += (long) backTexture << (8 * 3);
		qubeData += (long) frontTexture << (8 * 2);
		qubeData += (long) leftTexture << (8 * 1);
		qubeData += (long) rightTexture << (8 * 0);
	}

	public byte filled() {
		return (byte) ((qubeData >> (8 * 6)) & 0xff);
	}

	public byte rightTexture() {
		return (byte) (qubeData & 0xff);
	}

	public byte leftTexture() {
		return (byte) ((qubeData >> 8) & 0xff);
	}

	public byte frontTexture() {
		return (byte) ((qubeData >> (8 * 2)) & 0xff);
	}

	public byte backTexture() {
		return (byte) ((qubeData >> (8 * 3)) & 0xff);
	}

	public byte topTexture() {
		return (byte) ((qubeData >> (8 * 4)) & 0xff);
	}

	public byte bottomTexture() {
		return (byte) ((qubeData >> (8 * 5)) & 0xff);
	}
}